package controller;

import org.apache.commons.lang3.RandomStringUtils;
import util.JdbcUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;

/**
 * @author 高杰  gao4433@qq.com
 * @Description
 * @date 2021/12/16 16:21
 * @since 1.8
 */
public class GoodsAddServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        int categoryId = Integer.parseInt(request.getParameter("category")) ;
        String goodsName = request.getParameter("goodsName");
        String price = request.getParameter("price");
        String imgUrl = request.getParameter("imgUrl");
        String comments = request.getParameter("comments");



        String sql = "INSERT INTO `ec_simple_goods` (`cid`,`title`,`price`,`image`,`comment`) VALUES(?,?,?,?,?)";
        JdbcUtils.modify(sql, categoryId, goodsName, price, imgUrl, comments);
    }
}
